Skip to main content

symmetric difference

Type

command

Summary

Removes elements from a target array which have a corresponding element in a template array, and adds elements from the template array that have no which have no corresponding element in the target array.

Syntax

symmetric difference <targetArray> with <templateArray> [into <destinationArray>]

Description

Use the symmetric difference command to set the elements from an array according to the contents of another array.

Each key of targetArray is checked to see whether there is a matching key in templateArray. The elements of targetArray that match an element of the templateArray are removed from targetArray while the elements of the templateArray that have no corresponding element in the targetArray are added to the targetArray.

The content of individual elements of the templateArray does not affect the final result. Only which elements exist in the templateArray, not their content, controls which elements of targetArray are retained and which are removed.

If the into clause is used the operation of the commands is the same as the non-into form except that targetArray does not have to be a variable, and the result of the operation is placed into destinationArray rather than mutating targetArray.

Parameters

NameTypeDescription

targetArray

array

The value to modify.

templateArray

array

The array to symmetric difference targetArray with.

destinationArray

array

A variable to set as the destination instead of mutating targetArray

Examples

local tLeft, tRight
put "green" into tLeft["color"]
put "left" into tLeft["align"]

put "blue" into tRight["color"]
put "100" into tRight["width"]

symmetric difference tLeft with tRight

# RESULT
# the keys of tLeft = "align" & "width"
# tRight unchanged

command: split, union, intersect, difference

glossary: element, array, command, key

keyword: element

Compatibility and Support

Introduced

LiveCode 9.0

OS

mac

windows

linux

ios

android

Platforms

desktop

server

mobile

Thank you for your feedback!

Was this page helpful?